package com.zyy.zyy.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;


//全局配置类--配置跨域请求
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
    
    public void addCorsMappings(CorsRegistry registry){
        registry.addMapping("/**")//预访问路径
                .allowedOrigins("Http://localhost:8080","null")//请求来源
                .allowedMethods("GET","POST","PUT","OPTION","DELETE")//方法
                .allowCredentials(true)//允许携带
                .maxAge(3600);//最大时间
    }
}
